<?php
function smarty_function_offline_rating($params, &$smarty)
{
	$intUserId 		= isset($params['userid']) ? $params['userid'] : 0;	
	$intHint			= isset($params['hint']) ? $params['hint'] : 0;	
	$objVfriendUser	= new Vfriend_User();
	$objUstat		= $objVfriendUser->getUserStat($intUserId);	
	$intAright		= isset($objUstat['tactivity_rate_right']) ? $objUstat['tactivity_rate_right'] : 0;
	$intAwrong		= isset($objUstat['tactivity_rate_wrong']) ? $objUstat['tactivity_rate_wrong'] : 0;

	if($intAright == 0 && $intAwrong == 0) {
		$strClass = 'rblack';
	}elseif($intAright > 0 && $intAwrong == 0) {
		if($intAright < 10) {
			$strClass = 'rblue';
		} else {
			$strClass = 'rgreen';
		}
	}elseif($intAright == 0 && $intAwrong > 0) {
		if($intAwrong < 10) {
			$strClass = 'rorange';
		}else {
			$strClass = 'rred';
		}
	}elseif($intAright > 0 && $intAwrong > 0 && $intAright > $intAwrong) {
		$intRate = ($intAright/$intAwrong)*100;
		if($intRate > 75) {
			$strClass = 'rgreen';
		} else {	
			$strClass = 'rblue';
		}
	}elseif($intAright > 0 && $intAwrong > 0 && $intAright <= $intAwrong) {
		$intRate = ($intAwrong/$intAright)*100;
		if($intRate < 75) {
			$strClass = 'rorange';
		}else {
			$strClass = 'rred';
		}
	}
	$smarty->assign('strClass', $strClass);
	$smarty->assign('intAright', $intAright);
	$smarty->assign('intAwrong', $intAwrong);
	$smarty->assign('intHint', $intHint);
	$smarty->display(ROOT_DIR . '/library/Vfriend/Plugins/Tpl/offline-rating.tpl');
}
?>
